-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ci] [R-package] Fix memory leaks found by valgrind #3443
Conversation
Ok, I can see a few things from the first run (https://github.com/microsoft/LightGBM/pull/3443/checks?check_run_id=1224028806)
I'll try some fixes tonight |
@jameslamb you can simply try this:
|
thanks! to be clear, I know how to get UPDATE: nevermind, I read too fast. Now I see you meant "as a way to fix the issue in LGBM_BoosterGetNumPredict_R". Thanks! |
ok as of e80b68d, I got the valgrind test to fail!!! Notice in https://github.com/microsoft/LightGBM/pull/3443/checks?check_run_id=1236732464 that all other R tests are passing. Now that I know this test catches what we want, next I'm going to merge in the Once the test is passing, I'll move it to one that is triggered by a comment (not run on every build), since it takes about 30m to run. |
it seems the error is not related to lightgbm,
can we fix them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these shrinkage_to_fit is not efficiency, let us try to remove them.
added #3462 |
Can you please point me to a log where you see this? I looked through all the Windows jobs and couldn't find that, maybe I'm missing something. |
Sure, I can! Here it is: https://github.com/microsoft/LightGBM/runs/1264985038?check_suite_focus=true. Also, please take a look at
|
I believe we need the same quick fix: #3225. Can we add that warning message ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameslamb Thanks a lot for addressing review comments! LGTM, except one lint error about line length and some other nits.Feel free to merge after green CI.
yep I just noticed that too. Will do it in a separate PR right now |
Co-authored-by: Nikita Titov <[email protected]>
…to ci/r-valgrind-test
I opened #3469 , let's move this discussion there. Thanks for letting me know! I would have missed it. |
thanks for the help and reviews! I hope that with these changes, we'll be able to get |
@@ -393,7 +393,7 @@ std::string GBDT::SaveModelToString(int start_iteration, int num_iteration, int | |||
ss << loaded_parameter_ << "\n"; | |||
ss << "end of parameters" << '\n'; | |||
} | |||
return ss.str(); | |||
return std::move(ss.str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guolinke @jameslamb I just noticed that std::move
here produces the following compilation warnings:
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode_9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode_9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -Xclang -fopenmp (found version "3.1")
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "3.1")
-- Found OpenMP: TRUE (found version "3.1")
-- Performing Test MM_PREFETCH
-- Performing Test MM_PREFETCH - Success
-- Using _mm_prefetch
-- Performing Test MM_MALLOC
-- Performing Test MM_MALLOC - Success
-- Using _mm_malloc
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/runner/work/1/s/build
Scanning dependencies of target _lightgbm
[ 3%] Building CXX object CMakeFiles/_lightgbm.dir/src/application/application.cpp.o
[ 6%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/boosting.cpp.o
[ 9%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt_model_text.cpp.o
[ 12%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt.cpp.o
/Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:396:10: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
return std::move(ss.str());
^
/Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:396:10: note: remove std::move call here
return std::move(ss.str());
^~~~~~~~~~ ~
/Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:621:10: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
return std::move(feature_importances);
^
/Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:621:10: note: remove std::move call here
return std::move(feature_importances);
^~~~~~~~~~ ~
[ 15%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt_prediction.cpp.o
2 warnings generated.
[ 18%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/prediction_early_stop.cpp.o
[ 21%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/bin.cpp.o
[ 24%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/config.cpp.o
[ 27%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/config_auto.cpp.o
[ 30%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/dataset.cpp.o
[ 33%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/dataset_loader.cpp.o
[ 36%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/file_io.cpp.o
[ 39%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/json11.cpp.o
[ 42%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/metadata.cpp.o
[ 45%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/parser.cpp.o
[ 48%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/tree.cpp.o
[ 51%] Building CXX object CMakeFiles/_lightgbm.dir/src/metric/dcg_calculator.cpp.o
[ 54%] Building CXX object CMakeFiles/_lightgbm.dir/src/metric/metric.cpp.o
[ 57%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/ifaddrs_patch.cpp.o
[ 60%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linker_topo.cpp.o
[ 63%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linkers_mpi.cpp.o
[ 66%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linkers_socket.cpp.o
[ 69%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/network.cpp.o
[ 72%] Building CXX object CMakeFiles/_lightgbm.dir/src/objective/objective_function.cpp.o
[ 75%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/cuda_tree_learner.cpp.o
[ 78%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/data_parallel_tree_learner.cpp.o
[ 81%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/feature_parallel_tree_learner.cpp.o
[ 84%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/gpu_tree_learner.cpp.o
[ 87%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/serial_tree_learner.cpp.o
[ 90%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/tree_learner.cpp.o
[ 93%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/voting_parallel_tree_learner.cpp.o
[ 96%] Building CXX object CMakeFiles/_lightgbm.dir/src/c_api.cpp.o
[100%] Linking CXX shared library ../lib_lightgbm.so
[100%] Built target _lightgbm
I wonder is there any way to avoid both valgrind error and compilation warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh I'm not sure! Think @guolinke will have to answer this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In c++11, the compliers should be able to auto move the "local" object by return
call, so it is safe to remove std::move
.
However, it seems apple clang doesn't have this optimization...
To fix the warning, we can remove these std::move
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, it seems apple clang doesn't have this optimization...
I also saw these warnings with ordinary Clang on Ubuntu.
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
In #3338 ,
{lightgbm}
was rejected from CRAN for multiple failed submission attempts. As of that submission, the package was failing tests with a version of R instrumented to usevalgrind
.https://cran-archive.r-project.org/web/checks/2020/2020-10-02_check_results_lightgbm.html
This PR attempts to add a CI job that replicates these checks.
Notes